// Read context - Column
int firstLine = counter.getAndAdd(linesPerThread);
int lastLine = firstLine + linesPerThread - 1;
rs.absolute(firstLine - 1);
for (int i = firstLine; i <= lastLine; ++i) {
  rs.next();
  val1 = rs.getInt(1);
  ResultSetRunnable.delayfunc();
  val2 = rs.getString(2);
  ResultSetRunnable.delayfunc();
  val3 = rs.getString(3);
  ResultSetRunnable.delayfunc();
  val4 = rs.getDate(4);
  ResultSetRunnable.delayfunc();
  val5 = rs.getDouble(5);
  ResultSetRunnable.delayfunc();
  val6 = rs.getInt(6);
  ResultSetRunnable.delayfunc();
  val7 = rs.getDate(7);
  ResultSetRunnable.delayfunc();
  val8 = rs.getString(8);
  ResultSetRunnable.delayfunc();
}

// Read context - Line
int firstLine = counter.getAndAdd(linesPerThread);
int lastLine = firstLine + linesPerThread - 1;
rs.absolute(firstLine - 1);
for (int i = firstLine; i <= lastLine; ++i) {
  rs.next();
  val1 = rs.getInt(1);
  val2 = rs.getString(2);
  val3 = rs.getString(3);
  val4 = rs.getDate(4);
  val5 = rs.getDouble(5);
  val6 = rs.getInt(6);
  val7 = rs.getDate(7);
  val8 = rs.getString(8);

  ResultSetRunnable.delayfunc();
}

// Update context - Column
initUpdateValues();
int firstLine = counter.getAndAdd(linesPerThread);
int lastLine = firstLine + linesPerThread - 1;
rs.absolute(firstLine - 1);
for (int i = firstLine; i <= lastLine; ++i) {
  rs.next();
  ResultSetRunnable.delayfunc();
  rs.updateString(2, val2);
  ResultSetRunnable.delayfunc();
  rs.updateString(3, val3);
  ResultSetRunnable.delayfunc();
  rs.updateDate(4, val4);
  ResultSetRunnable.delayfunc();
  rs.updateDouble(5, val5);
  ResultSetRunnable.delayfunc();
  rs.updateInt(6, val6);
  ResultSetRunnable.delayfunc();
  rs.updateDate(7, val7);
  ResultSetRunnable.delayfunc();
  rs.updateString(8, val8);
  ResultSetRunnable.delayfunc();
  rs.updateRow();
}

// Update context - Line
initUpdateValues();
int firstLine = counter.getAndAdd(linesPerThread);
int lastLine = firstLine + linesPerThread - 1;
rs.absolute(firstLine - 1);
for (int i = firstLine; i <= lastLine; ++i) {
  rs.next();

  ResultSetRunnable.delayfunc();

  rs.updateString(2, val2);
  rs.updateString(3, val3);
  rs.updateDate(4, val4);
  rs.updateDouble(5, val5);
  rs.updateInt(6, val6);
  rs.updateDate(7, val7);
  rs.updateString(8, val8);

  rs.updateRow();
}

// Delay function
final static Object = new Object();
public static void delayfunc() {
  synchronized(obj) {
    obj.wait(delayms);
  }  
}
